/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package view.leftPanels;

import view.centerPanels.NewTableCentralPanel;
import view.main.MainGUI;

/**
 *
 * @author Vlada
 */
public class NewTablePnlLeft extends javax.swing.JPanel {

    public static int numOfColumns;
    
    /**
     * Creates new form NewTablePnlLeft
     */
    public NewTablePnlLeft() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txtFieldColumns = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();

        jLabel1.setText("Number of columns:");

        txtFieldColumns.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFieldColumnsActionPerformed(evt);
            }
        });

        jButton1.setText("Create table");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtFieldColumns, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addComponent(jButton1)))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(65, 65, 65)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtFieldColumns, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(80, 80, 80)
                .addComponent(jButton1)
                .addContainerGap(112, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void txtFieldColumnsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFieldColumnsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtFieldColumnsActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  String columns = txtFieldColumns.getText();
        numOfColumns = Integer.parseInt(columns); 
        
        MainGUI.getInstance().getPnlLeft().removeAll();
        
        AtributeNamesLeftPanel panel = new AtributeNamesLeftPanel();
            panel.setSize(MainGUI.getInstance().getPnlLeft().getSize());
            MainGUI.getInstance().getPnlLeft().removeAll();
            MainGUI.getInstance().getPnlLeft().add(panel);
            MainGUI.getInstance().validate();
            MainGUI.getInstance().repaint();
            
            panel.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField txtFieldColumns;
    // End of variables declaration//GEN-END:variables
}
